<?php
/**
 +------------------------------------------------------------------------------
 * ContentAction 内容管理方法
 +------------------------------------------------------------------------------
 * @category   SubAction
 * @package  app
 * @subpackage  Action
 * @author   朝闻道 <admin@iic.cn>
 * @date 2013-9-17
 * @time  下午2:43:00
 +------------------------------------------------------------------------------
 */
class ContentAction extends BaseAction{
	
	protected $product;
	function _initialize() {
		parent::_initialize ();
		import ( "Com.Product" );
		$this->product = new Product();
	}
	
	/**
	*内容管理综合页面
	*@date 2013-9-17
	*@time 下午2:43:39
	*/
	function all() {
	//内容管理综合页面
		parent::_cache(1,'cats');
		$this->cats_tree();
		$this->display();
	}//end all
	
	/**
	*获取分类下的产品
	*@date 2013-9-17
	*@time 下午3:40:11
	*/
	function index() {
	//获取分类下的产品
		$catid=intval($_REQUEST['cid']);
		
		//获取分类下品牌
		$brand = $this->product->brand($catid);
		
		self::catinfo($catid);
		$where=array();
		if($_REQUEST['brand']){
			$where['brand_id']=$_REQUEST['brand'];
		}
		if($_REQUEST['status'] ==='1' || $_REQUEST['status'] ==='0'){
			$where['status']=$_REQUEST['status'];
			$this->assign('status_',$_REQUEST['status']);
		}
		import('Com.Product');
		$produs = new Product(); 
		if($catid){
			$dao=D("ProductCat");
			$cte = $produs->catetochildren($catid);
			$cte = $produs->arr2to1($cte,'id');
			$where['category_tag_id']= array('IN',implode(',', $cte));
			//$where['mian_cat']= array('IN',implode(',', $cte));
			//$where['_String']='pc.category_tag_id IN('.implode(',', $cte).') OR p.mian_cat IN ('.implode(',', $cte).')';
			$this->assign('catid',$catid);
		}else{
			//便于显示无分类产品
			$dao=D("ProductRead");
		}
		$where=parent::create_where($where);//dump($where);exit;
		/*if(count($where)==1||$where['_String']){
			unset($where['_String']);
			$map=array();
			$map['pc.category_tag_id']= array('IN',implode(',', $cte));
			$map['p.mian_cat']= array('IN',implode(',', $cte));
			$map['_logic'] = 'or';
			$where['_complex'] = $map;
		}*/
		$count=$dao->where($where)->count();

		$this->assign("totalCount",$count);
		if($count>0){
			$page=new Page($count,$this->listrows);
			$list=$dao->where($where)->order($this->order)->limit($page->firstRow.','.$page->listRows)->select();
//  			echo $dao->getlastsql();
			//print_r($list);
			//获取价格
			foreach ($list as $key=>$vo){
				$list[$key]['attr'] = $this->product->protoattr($vo['id']);
				$list[$key]['cat'] = $this->product->procat($vo['id']);
			}
			$this->assign('list',$list);
		}
		$proids = $this->_arr2to1($list,'id');
		//优惠信息
		import ("Com.Coupon");
		$Coupon = new Coupon();		
		//获取巨划算信息
		$sale = $Coupon->product_coupon($proids,'SALE','product_id');
		$coupon['sale'] = field2key($sale,'product_id');		
		//获取大宗批发信息
		$big = $Coupon->product_package($proids,'BIG','product_ids');
		$coupon['big'] = field2key($big,'product_ids');
		
		$status=array();
		$status['0']='已下架';
		$status['1']='已上架';
		$this->assign('brand',$brand);
		$this->assign('catid',$catid);
		$this->assign('status',$status);
		$this->assign('where',$where);
		$this->assign('coupon',$coupon);
		$this->display();
	}//end index
	
	/**
	 *产品详细信息
	 *@date 2013-10-23
	 *@time 下午2:44:22
	 */
	function show(){
		$_proid = $_REQUEST['id'];
		$product = $this->product->oneproinfo( $_proid );
		if($product){
			//获取产品品牌信息
			$brand = $this->product->brandinfo($product['base']['brand_id']);
			//获取分类信息
			$cate = $this->product->catetoinfo($product['base']['mian_cat']);

			$this->assign('product',$product);
			$this->assign('brand',$brand[0]);
			$this->assign('cate',$cate[0]);
		}
		$this->display();
	}
	
	/**
	 *产品上下架
	 *@date 2013-10-23
	 *@time 下午2:44:22
	 */
	function status(){
		//上下架权限限制       “角色 待改 ”
		if($_SESSION['user_group_id']){
			$this->_ajm(300,'只有编辑人员才能操作产品信息。',1);
		}
				
		$_proid = empty($_GET['id']) ? $_REQUEST['ids'] : $_GET['id'];
		$status = $_GET['status'];
		if(!$_proid){
			$this->_ajm(300,'选择产品失败。',1);
		}
		
		if(!is_array($_proid)){
			$_proid = array($_proid);
		}
		
		//有价格的产品才能上架
		if($status == 1){
			$proid = self::check_sxj($_proid);
			//取差集，查找不满足的产品
			$diff_proid = array_diff($_proid,$proid);
			//取交集，满足上架的产品
			$_proid =array_intersect($proid,$_proid);
			if(empty($_proid)){
				$this->_ajm(300,'您所选的产品没有填写价格，请先填写价格后再上架！');
				exit;
			}
		}
		
		
		//更新主表
		$Product = M("Product");
		$where['id'] = is_array($_proid) ? array('IN',implode(',', $_proid)) : $_proid;

		$data['status'] = $status;
		$data['write_date'] = time();
		$reid = $Product->where($where)->save($data);
		if($reid){
			//更新O2O表
			$this->o2o_status($_proid,$status);
			if($diff_proid){
				$this->_ajm(200,'部分产品上架成功！编号为：'.implode(',',$diff_proid).'的产品没有填写价格,上架失败！');
			}else{
				$this->_ajm(200,'操作成功！',1);
			}
		}else{					
			$this->_ajm(300,'操作失败！',1);
		}
	}
	
	function check_sxj($_proid){
		$price_m = M('ProductPriceB2b');
		$where['product_id'] = is_array($_proid) ? array('IN',implode(',',$_proid )) : $_proid;
		$where['price'] =  array('GT',0);
		$where['jiayi'] =  array('GT',0);
		$where['jiaer'] =  array('GT',0);
		$where['jiasan'] =  array('GT',0);
		$where['jiasi'] =  array('GT',0);
		$res = $price_m->field('product_id')->where($where)->select();
		$res = $this->_arr2to1($res,'product_id');
		return $res;
	}
	
	/**
	*获取分类的信息
	*@date 2013-9-17
	*@time 下午2:44:22
	*/
	protected function catinfo($cid=0) {
	//获取分类的信息
		$res=array();
		if($cid==0){
			return $res;
		}
		$dao=D('Cat');
		$catinfo=$dao->info($cid);
		$this->assign('catinfo',$catinfo);
	}//end catinfo
	
	/**
	 *查询属性组
	 *@date 2013-9-27
	 *@time 上午11:47:51
	 */
	protected function attr_group() {
		//查询属性组
		$dao=M('AttributeGroup');
		$group=$dao->order('sequence DESC')->select();
		$this->assign('group',$group);
		$modelname=M("SystemConfig")->field('value,title')->where('element="modelname"')->select();
		$modelname=field2key($modelname, 'value');
		$this->assign('modelname',$modelname);
	}//end attr_group
	
	/**
	*定制suggest
	*@date 2013-9-27
	*@time 下午2:27:48
	*/
	function suggest() {
	//定制suggest
		$where=array();
		if($_REQUEST['name']){
			$where=array('name'=>$_REQUEST['name']);
			$list=parent::suggest($where,true);
			$res=array();
			foreach ($list as $v){
				$res[]=array($v['id'],$v['value']);
			}
			echo json_encode($res);
		}else{
			
			$list = parent::suggest($where ,true);
			foreach ($list as $key=>$vo){
				$list[$key]['price'] = $vo['price']/100;
			}
			echo json_encode($list);
		}
		
	}//end suggest
	

	/**
	 *从属性组中获取属性值
	 *@date 2013-10-29
	 *@time 下午3:59:03
	 */
	 function group_attribute(){
	 	//查询属性组
	 	$dao=M('AttributeGroup');
	 	$group=$dao->order('sequence DESC')->select();
	 	
	 	$dao=M('Attribute');
	 	$list = array();
	 	foreach ($group as $key=>$vo){
	 		$map['id'] = array('IN',$vo['attr_ids']);
	 		$res = $dao->where($map)->select();
	 		//$res = field2key($res,'id');
	 		$group[$key]['attrs'] = $res;
	 	}
	 	
	 	return $group;
	 	//print_r($group);
	 }
	 
	 /**
	  *获取产品属性值
	  *@date 2013-10-29
	  *@time 下午3:59:03
	  */
	 function product_attribute($proids){
	 	$proids = is_array($proids) ? $proids : array($proids);
	 	$dao=M('ProductAttribute');
	 	$list = array();
	 	foreach ($proids as $pid){
	 		$map['product_id'] = $pid; 
	 		$res = $dao->where($map)->field('attribute_id')->select();
	 		$res = field2key($res,'attribute_id');
	 		$list[$pid]  = $res;
	 	}
	 	return $list;
	 }
	 
	 
	
	/**
	*根据分类ID添加产品
	*@date 2013-9-17
	*@time 下午2:54:03
	*/
	function add() {
		//$this->display();exit;
		$_proid = $_REQUEST['id'];
		
		//获取属性名称
		$groupattr = S('groupattr');
		if(empty($groupattr)){
			$groupattr = $this->group_attribute();
			S('groupattr',$groupattr,300);
		}
		$this->assign("groupattr",$groupattr);
		
		
		
		//根据分类ID添加产品
		$catid=intval($_REQUEST['catid']);
		$this->assign('catid',$catid);
		
		//获取分类
		$catelist=F('procat');
		if(empty($catelist)){
			$catids = array(3,70,4,14,186,199);
			$catelist = $this->product->catetolevel($catids);
			F('procat',$catelist);
		}
		$catearr = self::cate_level_3($catelist);
		$this->assign('catelist',$catearr);
		//编辑，读取数据
		if($_proid){
			$product = $this->product->oneproinfo( $_proid );
			$this->assign('product',$product);

			//获取品牌名称
			$brand = $this->product->brandinfo($product['base']['brand_id']);
			$this->assign('brand',$brand[0]);
			
			//获取产品属性
			$productattr =$this->product_attribute($_proid);
			$this->assign("proattr",$productattr[$_proid]);
			
			//获取产品附属分类
			$procates =$this->product->procat($_proid,'*',array('type'=>2));
			$this->assign("procates",$procates);
			self::catinfo($product['base']['mian_cat']);
		}		
		
		//获取产品模型
		$dao = M("SystemConfig");
		$where =array();
		$where['element'] = 'modelname';
		$modelname = $dao->where($where)->select();
		
		$this->assign('modelname',$modelname);
		$this->assign('proid',$_proid);
		self::attr_group();		
		parent::add();
	}//end add
	
	function insert(){		
		$dao=M('Product');		
		$base = $_REQUEST['base'];
		$base['brand_id'] = $_REQUEST['brand_id'];
		$base['mian_cat'] = $_REQUEST['cat_id'];
		if($base['id']){
			$base['write_date'] = time();
			$handle = 'save';
		}else{
			$base['create_date']=time();
			//自动生成一个商品编码
			$base['code']=$base['code']?$base['code']:$base['mian_cat'].'_'.short(time());
			$handle = 'add';
			
		}
		$id=$dao->$handle($base);
		$proid = empty($base['id']) ? $id : $base['id'];
		
		//写入详细表
		self::update_desc($proid,$handle);	
		//写入图片表
		self::update_img($proid);
		//写入产品分类
		self::update_cat($proid,$handle);
		
		if(!$base['id']){
			////写入属性
			self::update_proattr($proid);	
			//写入附属分类
			self::update_cat_child($proid);		
			//写入价格信息
			self::insert_price($proid);
		}
		$this->_ajm(200,'数据保存成功,',1);
		
	}
	
	/**
	*更新详细信息
	*@date 2013-9-22
	*@time 下午6:27:19
	*/
	function update_desc($pid=0,$handle) {
	//更新详细信息
		$dao=M('ProductDescription');
		$base = $_REQUEST['base'];
		$des = $_REQUEST['des']; 
		$des['product_id'] = $pid;
		$des['name'] = $base['name'];
		$reid = $dao->where('product_id='.$pid)->$handle($des);
		if($reid<0){
			$this->_ajm('300','详细信息写入有误');
		}
	}//end update_desc
	
	/**
	*更新图片信息
	*@date 2013-9-22
	*@time 下午6:27:19
	*/
	function update_img($pid=0) {
	//更新详细信息
		$dao=M('ProductImage');
		$pics = $_REQUEST['pics'];
		$picsname = $_REQUEST['picsname'];
		if($pics){							
			foreach ($pics as $key=>$p){
				$picname = empty($picsname[$key]) ?　rand().'jpg' : $picsname[$key];
				$data['title'] = $picname;
				$data['url'] = $p;
				$data['product_id']=$pid;
				$data['status'] = 1;
				$id=$dao->add($data);
			}
			if(empty($id)){
				$this->_ajm('300','产品组图写入有误');
			}
		}
	}//end update_img
	
	
	/**
	 *更新价格信息
	 *@date 2013-9-22
	 *@time 下午6:27:19
	 */
	function insert_price($pid=0) {
	//更新价格信息
		$dao=M('ProductPriceB2b');
		$data['product_id'] = $pid;
		$data['minsale'] = 1;
		$data['ctime'] = time();
		$reid = $dao->add($data);
		if($reid<0){
			$this->_ajm('300','详细信息写入有误');
		}
	}//end update_price
	
	
	/**
	 *更新产品属性信息
	 *@date 2013-10-30
	 *@time 下午6:27:19
	 */
	function update_proattr($pid=0){
		$dao=M("ProductAttribute");
		$attrs = $_REQUEST['attrs'];		
		foreach ($attrs as $attr_id){
			$data['attribute_id'] = $attr_id;
			$data['product_id'] = $pid;
			$res = $dao->where($data)->find();
			if(empty($res)){
				$reid = $dao->add($data);
				if(!$reid){
					$this->_ajm('300','产品属性写入有误');
				}
			}
			
		}
	}
	
	
	/*
	 * ajax 更新产品属性
	 * @author tb
	 * @date 2014.03.05
	 * */
	function ajax_updateattr(){
		$attrid = $_REQUEST['attrid'];
		$proid = $_REQUEST['proid'];
		$ched = $_REQUEST['ched'];
		$dao=M("ProductAttribute");
		$data['product_id'] = $proid;
		$data['attribute_id'] = $attrid;
		if($ched == 'checked'){
			//执行添加
			$reid = $dao->add($data);
		}else{			
			//执行删除
			$reid = $dao->where($data)->delete();			
		}
		if($reid){
			$this->ajaxReturn(1);
		}else{
			$this->ajaxReturn(0);
		}
	}
	
	
	/*
	 * 更新产品属性
	 * @author tb
	 * @date 2014.03.05
	* */
	function ajax_updatecate(){
		$attrid = $_REQUEST['cateid'];
		$proid = $_REQUEST['proid'];
		$ched = $_REQUEST['ched'];
		$dao=M("ProductToCategoryTag");
		$data['product_id'] = $proid;
		$data['category_tag_id'] = $attrid;
		$data['type'] = 2;
		if($ched == 'checked'){
			//执行添加
			$reid = $dao->add($data);
		}else{
			//执行删除
			$reid = $dao->where($data)->delete();
		}
		if($reid){
			$this->ajaxReturn(1);
		}else{
			$this->ajaxReturn(0);
		}
	}
	
	/*
	 * 移除产品附属分类
	* @author tb
	* @date 2014.03.17
	* */
	function removecate(){
		$ids=$_REQUEST['ids'];
		$cate = $_REQUEST['cate'];
		if(!$ids || !$cate){
			$this->_ajm(300,'选择产品或者选择分类错误！');
		}
		$dao = M('ProductToCategoryTag');
		$where['product_id'] = array('IN',implode(',', $ids));
		$where['type'] = 2;
		$where['category_tag_id'] = $cate;
		$res = $dao->where($where)->delete();
		if($res===FALSE){
			$this->_ajm(300,'移出失败！');
		}else{
			$this->_ajm(200,'移出成功！');
		}
	}
	
	
	/**
	 *更新产品分类信息
	 *@date 2013-10-30
	 *@time 下午6:27:19
	 */
	function update_cat($pid=0,$handel){
		$dao = M("ProductToCategoryTag");
		//写入主分类  处理
		$data['category_tag_id'] = $_REQUEST['cat_id'];
		if($handel == 'add'){			
			$data['product_id'] = $pid;
			$data['type'] = 1;
			$reid = $dao->add($data);
			if(!$reid){
				$this->_ajm(300,'分类写入错误');
			}
		}else{
			$where['product_id'] = $pid;
			//$where['type'] = 1;	暂时去掉		
			$reid = $dao->where($where)->save($data);
		}
	}
	
	function update_cat_child($pid){
		$dao = M("ProductToCategoryTag");
		//写入附属分类处理
		$cateids = $_REQUEST['cateids'];
		//先删除产品ID下的所有附属分类
		$data = array();
		foreach ($cateids as $cid){
			$data['product_id'] = $pid;
			$data['category_tag_id'] = $cid;
			$data['type'] = 2;
			$dao->add($data);
		}
	}
	
	
	/**
	*修改商品信息
	*@date 2013-9-21
	*@time 上午10:36:01
	*/
	function edit() {
	//修改商品信息
		
	}//end edit
	
	/**
	 * 返回分类树
	 *@date 2013-6-3
	 *@time 下午4:57:17
	 */
	function cats_tree() {
		//返回分类树
		$cats=F("cats");
		$this->assign("cats",$cats);
		$cats=list_to_tree($cats,'id','parent_id');
		$cats=$cats[0]['_child'];
		$tree=self::tree($cats);
		$this->assign("tree",$tree);
	}//end cats_tree
	
	
	function tree($arr, $urls = 'Content/index') {
		$str = '';
		foreach ( $arr as $key => $v ) {
			$pid = isset ( $_REQUEST ['pid'] ) ? intval ( $_REQUEST ['pid'] ) : 1;
			$ckd = ($pid == $v ['id']) ? 'myselect="selected"' : '';
			if ($v ['level'] < 10) {
				$str .= "<li " . $ckd . "><a href=\"" . U ( $urls, array (
						"cid" => $v ['id']
				) ) . "\" target=\"ajax\" rel=\"jbsxBox\">" . $v ['name'] . '</a>';
				if ($v ['_child']) {
					$str .= "<ul>";
					$str .= self::tree ( $v ['_child'] );
					$str .= "</ul>";
				}
			} else {
				$str .= "<li><a href=\"javascript:void(0);\">" . $v ['name'] . '</a>';
			}
			$str .= "</li>";
		}
		return $str;
	}
	
	

	/**
	 * 选择分类
	 */
		function selectcate(){
			$proids = $_REQUEST['chpro'];
			
			$cate = $_REQUEST['cate'] ? $_REQUEST['cate'] : 3;
			$ajax = $_REQUEST['ajax'] ? $_REQUEST['ajax'] : 0; 
			$catalist = $this->product->catetochildren($cate);
			if($ajax == 1){
				$this->ajaxReturn($catalist);
			}else{
				$this->assign('proids',$proids);
				$this->assign('cate',$cate);
				$this->assign('catalist',$catalist);
				$this->display();
			}
		}
		
		/**
		 * 选择分类
		 */
		function editcate(){
			if ( $_REQUEST['todo'] == 'addcate' ) {
				$proids = $_REQUEST['chpro'];			
				$cate = $_REQUEST['cate'] ? $_REQUEST['cate'] : 3;
				$ajax = $_REQUEST['ajax'] ? $_REQUEST['ajax'] : 0;
				$catalist = $this->product->catetochildren($cate);
				$this->assign('cate',$cate);
				$this->assign('catalist',$catalist);
				$this->assign("ids",$_REQUEST['ids']);
				$this->assign("todo",$_REQUEST['ftodo']);
				$this->display();
			}else{
				$re['ids'] = implode(',',$_REQUEST['ids']);
				$re['ftodo'] = $_REQUEST['ftodo'];
				$re['action'] = 'editcate';
				die( json_encode( $re ) );
				//$this->display();
			}
		}

		/**
		 *绑定分类
		 */
		function bindcate(){
			$model = M('ProductToCategoryTag');
			$proids = $_REQUEST['ids'];
			$todo = $_REQUEST['todo'];
			
			$proids = explode(',', $proids);
			//$cate = $_REQUEST['maincate'] ? $_REQUEST['maincate'] : 3;   //主分类
			//获取分类
			
			//$cateids = $_REQUEST['checkbox_cate'] ? $_REQUEST['checkbox_cate'] : '' ; 
			$cateids = is_array($_REQUEST['cat_id']) ? $_REQUEST['cat_id'] : array($_REQUEST['cat_id']); 
			
			if($todo == 'miancate'){
				//修噶附属分类
				$type = 1;
			}elseif($todo == 'childcate'){
				$type = 2;
			}
			$item = '';
			foreach ($proids as $pid){
				$data['product_id'] = $where['product_id'] = $pid;				
				$data['type'] = $where['type'] = $type;							
				foreach ($cateids as $cid){
					$data['category_tag_id']  = $cid;
					$che_info = $model->where($where)->find();		//print_r($che_info);exit;	
					if($che_info && $che_info['category_tag_id'] == $cid){
						continue;
					}					
					if($type == 1){		
						$data['id'] = $che_info['id'];
						$res = $model->where($where)->save($data);  //print_r($model->getLastSql());exit;	
						//修改主分类
						$p_res = M('Product')->where('id='.$pid)->save(array('mian_cat'=>$cid));
						if($p_res === FALSE){
							$item .= '产品：'.$pid.'(分类：'.$cid.')&nbsp;&nbsp';
						}
						
					}elseif($type == 2){
						$res = $model->add($data);
					}
					
					if($res === FALSE){
						$item .= '产品：'.$pid.'(分类：'.$cid.')&nbsp;&nbsp;';
					}				
				}
			
			}
			
			if($item){
						$this->_ajm(300,$item.'绑定分类（或者产品主分类）错误，请把此错误信息截图给技术部，进行处理！');
			}else{
						$this->_ajm(200,'操作成功！');
			}

		}
		
	
		
		

		/**
		 *删除组图中的照片
		 */
		function del_groupimg(){
			$id = $_REQUEST['id'];
			$model = M('ProductImage');
			$reid = $model->delete($id);
			if($reid){
				//$this->_ajm(200,'333',1);
				$this->ajaxReturn(1);
			}else{
				$this->ajaxReturn(0);
			}
		}
		
	function attribute_s(){
		if ( $_REQUEST['todo'] == 'adddel' ) {
			//获取属性名称
			self::attr_group();
			$groupattr = $this->group_attribute();
			$this->assign("groupattr",$groupattr);
			$this->assign("ids",$_REQUEST['ids']);
			$this->assign("todo",$_REQUEST['ftodo']);
			$this->display();
		} elseif ( ($_REQUEST['todo'] == 'insert') || ($_REQUEST['todo'] == 'delete') ) {
			$tem = array();
			$ids = explode(',',$_REQUEST['ids']);
			$m = M('product_attribute');
			foreach ( $ids as $value ) {
				if ( !$value ) continue;
				foreach ( $_REQUEST['attrs'] as $attr ) {
					if ( !$attr ) continue;
					$data = array( 'product_id'   => $value, 'attribute_id' => $attr);
					if ( $_REQUEST['todo'] == 'insert' ) $m->add($data,array(),true);
					elseif ( $_REQUEST['todo'] == 'delete' ) $m->where($data)->delete();
					$tem[] = $m->getLastSql();
				}
			}
			die( json_encode( $tem ) );
		} else {
			$re['ids'] = implode(',',$_REQUEST['ids']);
			$re['ftodo'] = $_REQUEST['ftodo'];
			$re['action'] = 'attribute_s';
			die( json_encode( $re ) );
		}
	}	
	
	/*
	 * 分类变成 3级结构 （ 只适用于 3级结构）
 	 * */
	function cate_level_3($catelist = array()){
		foreach ($catelist as $key => $catec){
			foreach ($catec as $c_key => $cate){
				if($key == $c_key){
					$catearr[$key] = $cate;
					unset($catec[$key]);
				}
				//实现 3 级
				if($cate['level'] == 2){
					$catec[$cate['parent_id']]['child'][$cate['id']] = $cate;
					unset($catec[$c_key]);
				}
					
			}
			$catearr[$key]['child']= $catec;
		}
		return $catearr;
	} 

	
	/**
	*设置上传参数
	*@date 2013-9-22
	*@time 上午10:33:00
	*/
	function setpic() {
	//设置上传参数
		/*$iic_auth_key = sysmd5 (C ( 'ADMIN_ACCESS' ) . $_SERVER ['HTTP_USER_AGENT']);
		$iic_auth = authcode ('1-0-100-jpeg,jpg,png,gif-2-'.$catid, 'ENCODE', $iic_auth_key );
		$param=array();
		$param['more']=1;
		$param['isthumb']=0;
		$param['file_limit']=100;
		$param['file_types']='jpeg,jpg,png,gif';
		$param['file_size']=2;
		$param['moduleid']=$catid;
		$param['auth']=$iic_auth;
		$pic=U("Attachment/index",$param);
		$this->assign('piclink',$pic);*/
	}//end setpic
}//end ContentAction

